#/bin/bash

cur_path=$(cd `dirname $0`;pwd) 
save=$1
version=`cat ${cur_path}/version.txt`
project=`cat ${cur_path}/project.txt`

function addTag(){
	echo "docker tag ${1} chenjingdong/${project}-${2}:${version}"
	docker tag ${1} chenjingdong/${project}-${2}:${version}
	component=${2}
	echo "param2 ${2}"
	if [ "$3" == "save" ]; then
		mkdir -p ${cur_path}/../docker-tars/
		echo "docker save -o ${cur_path}/../docker-tars/${project}-${component}-${version}.tar chenjingdong/${project}-${component}:${version}"
		docker save -o ${cur_path}/../docker-tars/${project}-${component}-${version}.tar chenjingdong/${project}-${component}:${version}
	fi	
}

addTag chenjingdong/redis:6.2.2-alpine redis ${save}
addTag chenjingdong/role:220427 role ${save}
addTag postgis/postgis:14-3.3 postgis ${save}
addTag chenjingdong/nats:2.2.4-alpine nats ${save}